<template>
	<view class="html">
		<view class="top">
			<text>{{ list.title }}</text>
		</view>
		<view class="zzz">
			<text style="color: #007AFF;">{{ list.edituser }}</text>
			<text style="margin-left: 20rpx; color: #C8C7CC;">{{ list.addtime | timeFormat }}</text>
		</view>
		<view class="body">
			<view>
				<u-parse :content="list.content" @preview="preview" @navigate="navigate" ></u-parse>
			</view>
			<image :src="URL + list.picture" mode="" @click="clickImg" ></image>
		</view>
		<view class="bottom">
			<view style="color: #C8C7CC;">阅读{{ list.hits }}</view>
			<view class="right">
				<view>
					<text class="iconfont icon-pengyouquan"></text>
					<text>转到朋友圈</text>
				</view>
				<button open-type="share">
					<text class="iconfont icon-zhuanfa-mian"></text>
					<text>转发给朋友</text>
				</button>
				<view>
					<text class="iconfont icon-dianzan1"></text>
					<text>0</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import uParse from '@/components/u-parse/u-parse.vue'
import moment from 'moment';
import { IMGBASEURL } from '../../utils/config.js';
import { news } from '../../api/news.js';
export default {
	data() {
		return {
			URL: IMGBASEURL,
			list: [],
			id: ''
		};
	},
	onLoad(options) {
		this.id = options.id;
		this.getnews();
	},
	filters: {
		timeFormat(val) {
			return moment(val).format('YYYY-MM-DD HH:mm');
		}
	},
	// 发送给朋友
	onShareAppMessage() {
		return {
			title: '资讯', // 标题
			path: '/pages/dynamic/index' // 要分享的页面
		};
	},


	methods: {
		clickImg() {
		    wx.previewImage({
		        urls: [this.URL + this.list.picture],
		        current: '',
		    })
		},
		async getnews() {
			let res = await news({ id: this.id });
			console.log(res);
			this.list = res.data;
		}
	}
};
</script>

<style>
@import './../../static/style/dynamic.less';
</style>
